<?php

class IndexAction extends Action {

    /**
      +----------------------------------------------------------
     * 默认操作
      +----------------------------------------------------------
     */
    public function index() {
        $story = M("story");
        $this->assign("list", $story->limit(20)->select());
        $this->display();
    }

    public function detail() {
        $id = $_GET["id"];
        $story = M("story");
//        $detail=$story->where('id='.$id)->select();
//        dump(getId());
        $detail = $story->find($id);
//        dump($detail);
        C("SITE_NAME", $detail["story_title"]." - ". C("SITE_NAME"));
        $this->assign($detail);
        $this->display();
    }

    protected function getId() {
        $id = $_GET['id'] ? intval($_GET['id']) : '';
        if (empty($id)) {
            $this->success('非法请求');
        } else {
            return $id;
        }
    }

    /**
      +----------------------------------------------------------
     * 探针模式
      +----------------------------------------------------------
     */
    public function checkEnv() {
        load('pointer', THINK_PATH . '/Tpl/Autoindex'); //载入探针函数
        $env_table = check_env(); //根据当前函数获取当前环境
        echo $env_table;
    }

    public function hello() {
        echo "hello," . $_GET["id"];
    }

}

?>